/* eslint-disable */
import _m0 from "protobufjs/minimal";
import { FieldMask } from "../../google/protobuf/field_mask";
import { Timestamp } from "../../google/protobuf/timestamp";
import { RowStatus, Visibility } from "./common";

export const protobufPackage = "slash.api.v1";

export interface Shortcut {
  id: number;
  creatorId: number;
  createdTime: Date | undefined;
  updatedTime: Date | undefined;
  rowStatus: RowStatus;
  name: string;
  link: string;
  alternativeLink: string;
  type: string;
  title: string;
  tags: string[];
  series: string[];
  description: string;
  collectionIds: number[];
  visibility: Visibility;
  viewCount: number;
  ogMetadata: OpenGraphMetadata | undefined;
  persisted: boolean;
}

export interface OpenGraphMetadata {
  title: string;
  description: string;
  image: string;
}

export interface CountShortcutsRequest {
  collectionIds: number[];
  search: string;
  type: string;
}

export interface CountShortcutsResponse {
  count: number;
}

export interface ListShortcutsRequest {
  pageNumber: number;
  pageSize: number;
  collectionIds: number[];
  search: string;
  type: string;
}

export interface ListShortcutsResponse {
  shortcuts: Shortcut[];
}

export interface GetShortcutRequest {
  id: number;
}

export interface GetShortcutResponse {
  shortcut: Shortcut | undefined;
}

export interface GetShortcutByNameRequest {
  name: string;
}

export interface GetShortcutByNameResponse {
  shortcut: Shortcut | undefined;
}

export interface CreateShortcutRequest {
  shortcut: Shortcut | undefined;
}

export interface CreateShortcutResponse {
  shortcut: Shortcut | undefined;
}

export interface BatchUpdateShortcutsRequest {
  ids: number[];
  rowStatus: RowStatus;
  collectionIds: number[];
  visibility: Visibility;
  type: string;
  tag: string;
  series: string;
  updateMask: string[] | undefined;
}

export interface BatchUpdateShortcutsResponse {
  count: number;
}

export interface UpdateShortcutRequest {
  shortcut: Shortcut | undefined;
  updateMask: string[] | undefined;
}

export interface UpdateShortcutResponse {
  shortcut: Shortcut | undefined;
}

export interface UpdateShortcutsRequest {
  ids: number[];
  collectionIds: number[];
  updateMask: string[] | undefined;
}

export interface UpdateShortcutsResponse {
  count: number;
}

export interface DeleteShortcutRequest {
  id: number;
}

export interface DeleteShortcutResponse {
}

export interface BatchDeleteShortcutsRequest {
  ids: number[];
}

export interface BatchDeleteShortcutsResponse {
  count: number;
}

export interface GetShortcutAnalyticsRequest {
  id: number;
}

export interface GetShortcutAnalyticsResponse {
  references: GetShortcutAnalyticsResponse_AnalyticsItem[];
  devices: GetShortcutAnalyticsResponse_AnalyticsItem[];
  browsers: GetShortcutAnalyticsResponse_AnalyticsItem[];
}

export interface GetShortcutAnalyticsResponse_AnalyticsItem {
  name: string;
  count: number;
}

function createBaseShortcut(): Shortcut {
  return {
    id: 0,
    creatorId: 0,
    createdTime: undefined,
    updatedTime: undefined,
    rowStatus: 0,
    name: "",
    link: "",
    alternativeLink: "",
    type: "",
    title: "",
    tags: [],
    series: [],
    description: "",
    collectionIds: [],
    visibility: 0,
    viewCount: 0,
    ogMetadata: undefined,
    persisted: false,
  };
}

export const Shortcut = {
  encode(message: Shortcut, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    if (message.creatorId !== 0) {
      writer.uint32(16).int32(message.creatorId);
    }
    if (message.createdTime !== undefined) {
      Timestamp.encode(toTimestamp(message.createdTime), writer.uint32(26).fork()).ldelim();
    }
    if (message.updatedTime !== undefined) {
      Timestamp.encode(toTimestamp(message.updatedTime), writer.uint32(34).fork()).ldelim();
    }
    if (message.rowStatus !== 0) {
      writer.uint32(40).int32(message.rowStatus);
    }
    if (message.name !== "") {
      writer.uint32(50).string(message.name);
    }
    if (message.link !== "") {
      writer.uint32(58).string(message.link);
    }
    if (message.alternativeLink !== "") {
      writer.uint32(66).string(message.alternativeLink);
    }
    if (message.type !== "") {
      writer.uint32(74).string(message.type);
    }
    if (message.title !== "") {
      writer.uint32(82).string(message.title);
    }
    for (const v of message.tags) {
      writer.uint32(90).string(v!);
    }
    for (const v of message.series) {
      writer.uint32(98).string(v!);
    }
    if (message.description !== "") {
      writer.uint32(106).string(message.description);
    }
    writer.uint32(114).fork();
    for (const v of message.collectionIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.visibility !== 0) {
      writer.uint32(120).int32(message.visibility);
    }
    if (message.viewCount !== 0) {
      writer.uint32(128).int32(message.viewCount);
    }
    if (message.ogMetadata !== undefined) {
      OpenGraphMetadata.encode(message.ogMetadata, writer.uint32(138).fork()).ldelim();
    }
    if (message.persisted === true) {
      writer.uint32(144).bool(message.persisted);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): Shortcut {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseShortcut();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.creatorId = reader.int32();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.createdTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
          continue;
        case 4:
          if (tag !== 34) {
            break;
          }

          message.updatedTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
          continue;
        case 5:
          if (tag !== 40) {
            break;
          }

          message.rowStatus = reader.int32() as any;
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }

          message.name = reader.string();
          continue;
        case 7:
          if (tag !== 58) {
            break;
          }

          message.link = reader.string();
          continue;
        case 8:
          if (tag !== 66) {
            break;
          }

          message.alternativeLink = reader.string();
          continue;
        case 9:
          if (tag !== 74) {
            break;
          }

          message.type = reader.string();
          continue;
        case 10:
          if (tag !== 82) {
            break;
          }

          message.title = reader.string();
          continue;
        case 11:
          if (tag !== 90) {
            break;
          }

          message.tags.push(reader.string());
          continue;
        case 12:
          if (tag !== 98) {
            break;
          }

          message.series.push(reader.string());
          continue;
        case 13:
          if (tag !== 106) {
            break;
          }

          message.description = reader.string();
          continue;
        case 14:
          if (tag === 112) {
            message.collectionIds.push(reader.int32());

            continue;
          }

          if (tag === 114) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.collectionIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 15:
          if (tag !== 120) {
            break;
          }

          message.visibility = reader.int32() as any;
          continue;
        case 16:
          if (tag !== 128) {
            break;
          }

          message.viewCount = reader.int32();
          continue;
        case 17:
          if (tag !== 138) {
            break;
          }

          message.ogMetadata = OpenGraphMetadata.decode(reader, reader.uint32());
          continue;
        case 18:
          if (tag !== 144) {
            break;
          }

          message.persisted = reader.bool();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<Shortcut>): Shortcut {
    return Shortcut.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<Shortcut>): Shortcut {
    const message = createBaseShortcut();
    message.id = object.id ?? 0;
    message.creatorId = object.creatorId ?? 0;
    message.createdTime = object.createdTime ?? undefined;
    message.updatedTime = object.updatedTime ?? undefined;
    message.rowStatus = object.rowStatus ?? 0;
    message.name = object.name ?? "";
    message.link = object.link ?? "";
    message.alternativeLink = object.alternativeLink ?? "";
    message.type = object.type ?? "";
    message.title = object.title ?? "";
    message.tags = object.tags?.map((e) => e) || [];
    message.series = object.series?.map((e) => e) || [];
    message.description = object.description ?? "";
    message.collectionIds = object.collectionIds?.map((e) => e) || [];
    message.visibility = object.visibility ?? 0;
    message.viewCount = object.viewCount ?? 0;
    message.ogMetadata = (object.ogMetadata !== undefined && object.ogMetadata !== null)
      ? OpenGraphMetadata.fromPartial(object.ogMetadata)
      : undefined;
    message.persisted = object.persisted ?? false;
    return message;
  },
};

function createBaseOpenGraphMetadata(): OpenGraphMetadata {
  return { title: "", description: "", image: "" };
}

export const OpenGraphMetadata = {
  encode(message: OpenGraphMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.title !== "") {
      writer.uint32(10).string(message.title);
    }
    if (message.description !== "") {
      writer.uint32(18).string(message.description);
    }
    if (message.image !== "") {
      writer.uint32(26).string(message.image);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): OpenGraphMetadata {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseOpenGraphMetadata();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.title = reader.string();
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.description = reader.string();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.image = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<OpenGraphMetadata>): OpenGraphMetadata {
    return OpenGraphMetadata.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<OpenGraphMetadata>): OpenGraphMetadata {
    const message = createBaseOpenGraphMetadata();
    message.title = object.title ?? "";
    message.description = object.description ?? "";
    message.image = object.image ?? "";
    return message;
  },
};

function createBaseCountShortcutsRequest(): CountShortcutsRequest {
  return { collectionIds: [], search: "", type: "" };
}

export const CountShortcutsRequest = {
  encode(message: CountShortcutsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    writer.uint32(10).fork();
    for (const v of message.collectionIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.search !== "") {
      writer.uint32(18).string(message.search);
    }
    if (message.type !== "") {
      writer.uint32(26).string(message.type);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CountShortcutsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCountShortcutsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag === 8) {
            message.collectionIds.push(reader.int32());

            continue;
          }

          if (tag === 10) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.collectionIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.search = reader.string();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.type = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CountShortcutsRequest>): CountShortcutsRequest {
    return CountShortcutsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CountShortcutsRequest>): CountShortcutsRequest {
    const message = createBaseCountShortcutsRequest();
    message.collectionIds = object.collectionIds?.map((e) => e) || [];
    message.search = object.search ?? "";
    message.type = object.type ?? "";
    return message;
  },
};

function createBaseCountShortcutsResponse(): CountShortcutsResponse {
  return { count: 0 };
}

export const CountShortcutsResponse = {
  encode(message: CountShortcutsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.count !== 0) {
      writer.uint32(8).int32(message.count);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CountShortcutsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCountShortcutsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.count = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CountShortcutsResponse>): CountShortcutsResponse {
    return CountShortcutsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CountShortcutsResponse>): CountShortcutsResponse {
    const message = createBaseCountShortcutsResponse();
    message.count = object.count ?? 0;
    return message;
  },
};

function createBaseListShortcutsRequest(): ListShortcutsRequest {
  return { pageNumber: 0, pageSize: 0, collectionIds: [], search: "", type: "" };
}

export const ListShortcutsRequest = {
  encode(message: ListShortcutsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.pageNumber !== 0) {
      writer.uint32(8).int32(message.pageNumber);
    }
    if (message.pageSize !== 0) {
      writer.uint32(16).int32(message.pageSize);
    }
    writer.uint32(26).fork();
    for (const v of message.collectionIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.search !== "") {
      writer.uint32(34).string(message.search);
    }
    if (message.type !== "") {
      writer.uint32(42).string(message.type);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): ListShortcutsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListShortcutsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.pageNumber = reader.int32();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.pageSize = reader.int32();
          continue;
        case 3:
          if (tag === 24) {
            message.collectionIds.push(reader.int32());

            continue;
          }

          if (tag === 26) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.collectionIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 4:
          if (tag !== 34) {
            break;
          }

          message.search = reader.string();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }

          message.type = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<ListShortcutsRequest>): ListShortcutsRequest {
    return ListShortcutsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<ListShortcutsRequest>): ListShortcutsRequest {
    const message = createBaseListShortcutsRequest();
    message.pageNumber = object.pageNumber ?? 0;
    message.pageSize = object.pageSize ?? 0;
    message.collectionIds = object.collectionIds?.map((e) => e) || [];
    message.search = object.search ?? "";
    message.type = object.type ?? "";
    return message;
  },
};

function createBaseListShortcutsResponse(): ListShortcutsResponse {
  return { shortcuts: [] };
}

export const ListShortcutsResponse = {
  encode(message: ListShortcutsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    for (const v of message.shortcuts) {
      Shortcut.encode(v!, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): ListShortcutsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListShortcutsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcuts.push(Shortcut.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<ListShortcutsResponse>): ListShortcutsResponse {
    return ListShortcutsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<ListShortcutsResponse>): ListShortcutsResponse {
    const message = createBaseListShortcutsResponse();
    message.shortcuts = object.shortcuts?.map((e) => Shortcut.fromPartial(e)) || [];
    return message;
  },
};

function createBaseGetShortcutRequest(): GetShortcutRequest {
  return { id: 0 };
}

export const GetShortcutRequest = {
  encode(message: GetShortcutRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutRequest>): GetShortcutRequest {
    return GetShortcutRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutRequest>): GetShortcutRequest {
    const message = createBaseGetShortcutRequest();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseGetShortcutResponse(): GetShortcutResponse {
  return { shortcut: undefined };
}

export const GetShortcutResponse = {
  encode(message: GetShortcutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutResponse>): GetShortcutResponse {
    return GetShortcutResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutResponse>): GetShortcutResponse {
    const message = createBaseGetShortcutResponse();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    return message;
  },
};

function createBaseGetShortcutByNameRequest(): GetShortcutByNameRequest {
  return { name: "" };
}

export const GetShortcutByNameRequest = {
  encode(message: GetShortcutByNameRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutByNameRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutByNameRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.name = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutByNameRequest>): GetShortcutByNameRequest {
    return GetShortcutByNameRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutByNameRequest>): GetShortcutByNameRequest {
    const message = createBaseGetShortcutByNameRequest();
    message.name = object.name ?? "";
    return message;
  },
};

function createBaseGetShortcutByNameResponse(): GetShortcutByNameResponse {
  return { shortcut: undefined };
}

export const GetShortcutByNameResponse = {
  encode(message: GetShortcutByNameResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutByNameResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutByNameResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutByNameResponse>): GetShortcutByNameResponse {
    return GetShortcutByNameResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutByNameResponse>): GetShortcutByNameResponse {
    const message = createBaseGetShortcutByNameResponse();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    return message;
  },
};

function createBaseCreateShortcutRequest(): CreateShortcutRequest {
  return { shortcut: undefined };
}

export const CreateShortcutRequest = {
  encode(message: CreateShortcutRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CreateShortcutRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCreateShortcutRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CreateShortcutRequest>): CreateShortcutRequest {
    return CreateShortcutRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CreateShortcutRequest>): CreateShortcutRequest {
    const message = createBaseCreateShortcutRequest();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    return message;
  },
};

function createBaseCreateShortcutResponse(): CreateShortcutResponse {
  return { shortcut: undefined };
}

export const CreateShortcutResponse = {
  encode(message: CreateShortcutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CreateShortcutResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCreateShortcutResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CreateShortcutResponse>): CreateShortcutResponse {
    return CreateShortcutResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CreateShortcutResponse>): CreateShortcutResponse {
    const message = createBaseCreateShortcutResponse();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    return message;
  },
};

function createBaseBatchUpdateShortcutsRequest(): BatchUpdateShortcutsRequest {
  return {
    ids: [],
    rowStatus: 0,
    collectionIds: [],
    visibility: 0,
    type: "",
    tag: "",
    series: "",
    updateMask: undefined,
  };
}

export const BatchUpdateShortcutsRequest = {
  encode(message: BatchUpdateShortcutsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    writer.uint32(10).fork();
    for (const v of message.ids) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.rowStatus !== 0) {
      writer.uint32(16).int32(message.rowStatus);
    }
    writer.uint32(26).fork();
    for (const v of message.collectionIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.visibility !== 0) {
      writer.uint32(32).int32(message.visibility);
    }
    if (message.type !== "") {
      writer.uint32(42).string(message.type);
    }
    if (message.tag !== "") {
      writer.uint32(50).string(message.tag);
    }
    if (message.series !== "") {
      writer.uint32(58).string(message.series);
    }
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(66).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): BatchUpdateShortcutsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBatchUpdateShortcutsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag === 8) {
            message.ids.push(reader.int32());

            continue;
          }

          if (tag === 10) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.ids.push(reader.int32());
            }

            continue;
          }

          break;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.rowStatus = reader.int32() as any;
          continue;
        case 3:
          if (tag === 24) {
            message.collectionIds.push(reader.int32());

            continue;
          }

          if (tag === 26) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.collectionIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 4:
          if (tag !== 32) {
            break;
          }

          message.visibility = reader.int32() as any;
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }

          message.type = reader.string();
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }

          message.tag = reader.string();
          continue;
        case 7:
          if (tag !== 58) {
            break;
          }

          message.series = reader.string();
          continue;
        case 8:
          if (tag !== 66) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<BatchUpdateShortcutsRequest>): BatchUpdateShortcutsRequest {
    return BatchUpdateShortcutsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<BatchUpdateShortcutsRequest>): BatchUpdateShortcutsRequest {
    const message = createBaseBatchUpdateShortcutsRequest();
    message.ids = object.ids?.map((e) => e) || [];
    message.rowStatus = object.rowStatus ?? 0;
    message.collectionIds = object.collectionIds?.map((e) => e) || [];
    message.visibility = object.visibility ?? 0;
    message.type = object.type ?? "";
    message.tag = object.tag ?? "";
    message.series = object.series ?? "";
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

function createBaseBatchUpdateShortcutsResponse(): BatchUpdateShortcutsResponse {
  return { count: 0 };
}

export const BatchUpdateShortcutsResponse = {
  encode(message: BatchUpdateShortcutsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.count !== 0) {
      writer.uint32(8).int32(message.count);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): BatchUpdateShortcutsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBatchUpdateShortcutsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.count = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<BatchUpdateShortcutsResponse>): BatchUpdateShortcutsResponse {
    return BatchUpdateShortcutsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<BatchUpdateShortcutsResponse>): BatchUpdateShortcutsResponse {
    const message = createBaseBatchUpdateShortcutsResponse();
    message.count = object.count ?? 0;
    return message;
  },
};

function createBaseUpdateShortcutRequest(): UpdateShortcutRequest {
  return { shortcut: undefined, updateMask: undefined };
}

export const UpdateShortcutRequest = {
  encode(message: UpdateShortcutRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateShortcutRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateShortcutRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateShortcutRequest>): UpdateShortcutRequest {
    return UpdateShortcutRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateShortcutRequest>): UpdateShortcutRequest {
    const message = createBaseUpdateShortcutRequest();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

function createBaseUpdateShortcutResponse(): UpdateShortcutResponse {
  return { shortcut: undefined };
}

export const UpdateShortcutResponse = {
  encode(message: UpdateShortcutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.shortcut !== undefined) {
      Shortcut.encode(message.shortcut, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateShortcutResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateShortcutResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.shortcut = Shortcut.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateShortcutResponse>): UpdateShortcutResponse {
    return UpdateShortcutResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateShortcutResponse>): UpdateShortcutResponse {
    const message = createBaseUpdateShortcutResponse();
    message.shortcut = (object.shortcut !== undefined && object.shortcut !== null)
      ? Shortcut.fromPartial(object.shortcut)
      : undefined;
    return message;
  },
};

function createBaseUpdateShortcutsRequest(): UpdateShortcutsRequest {
  return { ids: [], collectionIds: [], updateMask: undefined };
}

export const UpdateShortcutsRequest = {
  encode(message: UpdateShortcutsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    writer.uint32(10).fork();
    for (const v of message.ids) {
      writer.int32(v);
    }
    writer.ldelim();
    writer.uint32(26).fork();
    for (const v of message.collectionIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateShortcutsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateShortcutsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag === 8) {
            message.ids.push(reader.int32());

            continue;
          }

          if (tag === 10) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.ids.push(reader.int32());
            }

            continue;
          }

          break;
        case 3:
          if (tag === 24) {
            message.collectionIds.push(reader.int32());

            continue;
          }

          if (tag === 26) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.collectionIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateShortcutsRequest>): UpdateShortcutsRequest {
    return UpdateShortcutsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateShortcutsRequest>): UpdateShortcutsRequest {
    const message = createBaseUpdateShortcutsRequest();
    message.ids = object.ids?.map((e) => e) || [];
    message.collectionIds = object.collectionIds?.map((e) => e) || [];
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

function createBaseUpdateShortcutsResponse(): UpdateShortcutsResponse {
  return { count: 0 };
}

export const UpdateShortcutsResponse = {
  encode(message: UpdateShortcutsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.count !== 0) {
      writer.uint32(8).int32(message.count);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateShortcutsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateShortcutsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.count = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateShortcutsResponse>): UpdateShortcutsResponse {
    return UpdateShortcutsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateShortcutsResponse>): UpdateShortcutsResponse {
    const message = createBaseUpdateShortcutsResponse();
    message.count = object.count ?? 0;
    return message;
  },
};

function createBaseDeleteShortcutRequest(): DeleteShortcutRequest {
  return { id: 0 };
}

export const DeleteShortcutRequest = {
  encode(message: DeleteShortcutRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): DeleteShortcutRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseDeleteShortcutRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<DeleteShortcutRequest>): DeleteShortcutRequest {
    return DeleteShortcutRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<DeleteShortcutRequest>): DeleteShortcutRequest {
    const message = createBaseDeleteShortcutRequest();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseDeleteShortcutResponse(): DeleteShortcutResponse {
  return {};
}

export const DeleteShortcutResponse = {
  encode(_: DeleteShortcutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): DeleteShortcutResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseDeleteShortcutResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<DeleteShortcutResponse>): DeleteShortcutResponse {
    return DeleteShortcutResponse.fromPartial(base ?? {});
  },

  fromPartial(_: DeepPartial<DeleteShortcutResponse>): DeleteShortcutResponse {
    const message = createBaseDeleteShortcutResponse();
    return message;
  },
};

function createBaseBatchDeleteShortcutsRequest(): BatchDeleteShortcutsRequest {
  return { ids: [] };
}

export const BatchDeleteShortcutsRequest = {
  encode(message: BatchDeleteShortcutsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    writer.uint32(10).fork();
    for (const v of message.ids) {
      writer.int32(v);
    }
    writer.ldelim();
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): BatchDeleteShortcutsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBatchDeleteShortcutsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag === 8) {
            message.ids.push(reader.int32());

            continue;
          }

          if (tag === 10) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.ids.push(reader.int32());
            }

            continue;
          }

          break;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<BatchDeleteShortcutsRequest>): BatchDeleteShortcutsRequest {
    return BatchDeleteShortcutsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<BatchDeleteShortcutsRequest>): BatchDeleteShortcutsRequest {
    const message = createBaseBatchDeleteShortcutsRequest();
    message.ids = object.ids?.map((e) => e) || [];
    return message;
  },
};

function createBaseBatchDeleteShortcutsResponse(): BatchDeleteShortcutsResponse {
  return { count: 0 };
}

export const BatchDeleteShortcutsResponse = {
  encode(message: BatchDeleteShortcutsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.count !== 0) {
      writer.uint32(8).int32(message.count);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): BatchDeleteShortcutsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBatchDeleteShortcutsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.count = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<BatchDeleteShortcutsResponse>): BatchDeleteShortcutsResponse {
    return BatchDeleteShortcutsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<BatchDeleteShortcutsResponse>): BatchDeleteShortcutsResponse {
    const message = createBaseBatchDeleteShortcutsResponse();
    message.count = object.count ?? 0;
    return message;
  },
};

function createBaseGetShortcutAnalyticsRequest(): GetShortcutAnalyticsRequest {
  return { id: 0 };
}

export const GetShortcutAnalyticsRequest = {
  encode(message: GetShortcutAnalyticsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutAnalyticsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutAnalyticsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutAnalyticsRequest>): GetShortcutAnalyticsRequest {
    return GetShortcutAnalyticsRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutAnalyticsRequest>): GetShortcutAnalyticsRequest {
    const message = createBaseGetShortcutAnalyticsRequest();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseGetShortcutAnalyticsResponse(): GetShortcutAnalyticsResponse {
  return { references: [], devices: [], browsers: [] };
}

export const GetShortcutAnalyticsResponse = {
  encode(message: GetShortcutAnalyticsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    for (const v of message.references) {
      GetShortcutAnalyticsResponse_AnalyticsItem.encode(v!, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.devices) {
      GetShortcutAnalyticsResponse_AnalyticsItem.encode(v!, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.browsers) {
      GetShortcutAnalyticsResponse_AnalyticsItem.encode(v!, writer.uint32(26).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutAnalyticsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutAnalyticsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.references.push(GetShortcutAnalyticsResponse_AnalyticsItem.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.devices.push(GetShortcutAnalyticsResponse_AnalyticsItem.decode(reader, reader.uint32()));
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.browsers.push(GetShortcutAnalyticsResponse_AnalyticsItem.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutAnalyticsResponse>): GetShortcutAnalyticsResponse {
    return GetShortcutAnalyticsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetShortcutAnalyticsResponse>): GetShortcutAnalyticsResponse {
    const message = createBaseGetShortcutAnalyticsResponse();
    message.references = object.references?.map((e) => GetShortcutAnalyticsResponse_AnalyticsItem.fromPartial(e)) || [];
    message.devices = object.devices?.map((e) => GetShortcutAnalyticsResponse_AnalyticsItem.fromPartial(e)) || [];
    message.browsers = object.browsers?.map((e) => GetShortcutAnalyticsResponse_AnalyticsItem.fromPartial(e)) || [];
    return message;
  },
};

function createBaseGetShortcutAnalyticsResponse_AnalyticsItem(): GetShortcutAnalyticsResponse_AnalyticsItem {
  return { name: "", count: 0 };
}

export const GetShortcutAnalyticsResponse_AnalyticsItem = {
  encode(message: GetShortcutAnalyticsResponse_AnalyticsItem, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.count !== 0) {
      writer.uint32(16).int32(message.count);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetShortcutAnalyticsResponse_AnalyticsItem {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetShortcutAnalyticsResponse_AnalyticsItem();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.name = reader.string();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.count = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetShortcutAnalyticsResponse_AnalyticsItem>): GetShortcutAnalyticsResponse_AnalyticsItem {
    return GetShortcutAnalyticsResponse_AnalyticsItem.fromPartial(base ?? {});
  },

  fromPartial(
    object: DeepPartial<GetShortcutAnalyticsResponse_AnalyticsItem>,
  ): GetShortcutAnalyticsResponse_AnalyticsItem {
    const message = createBaseGetShortcutAnalyticsResponse_AnalyticsItem();
    message.name = object.name ?? "";
    message.count = object.count ?? 0;
    return message;
  },
};

export type ShortcutServiceDefinition = typeof ShortcutServiceDefinition;
export const ShortcutServiceDefinition = {
  name: "ShortcutService",
  fullName: "slash.api.v1.ShortcutService",
  methods: {
    /** ListShortcuts returns a list of shortcuts. */
    listShortcuts: {
      name: "ListShortcuts",
      requestType: ListShortcutsRequest,
      requestStream: false,
      responseType: ListShortcutsResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([19, 18, 17, 47, 97, 112, 105, 47, 118, 49, 47, 115, 104, 111, 114, 116, 99, 117, 116, 115]),
          ],
        },
      },
    },
    countShortcuts: {
      name: "CountShortcuts",
      requestType: CountShortcutsRequest,
      requestStream: false,
      responseType: CountShortcutsResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              25,
              18,
              23,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
              47,
              99,
              111,
              117,
              110,
              116,
            ]),
          ],
        },
      },
    },
    /** GetShortcut returns a shortcut by id. */
    getShortcut: {
      name: "GetShortcut",
      requestType: GetShortcutRequest,
      requestStream: false,
      responseType: GetShortcutResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([2, 105, 100])],
          578365826: [
            new Uint8Array([
              24,
              18,
              22,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
              47,
              123,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
    /** GetShortcutByName returns a shortcut by name. */
    getShortcutByName: {
      name: "GetShortcutByName",
      requestType: GetShortcutByNameRequest,
      requestStream: false,
      responseType: GetShortcutByNameResponse,
      responseStream: false,
      options: {},
    },
    /** CreateShortcut creates a shortcut. */
    createShortcut: {
      name: "CreateShortcut",
      requestType: CreateShortcutRequest,
      requestStream: false,
      responseType: CreateShortcutResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              29,
              58,
              8,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              34,
              17,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
            ]),
          ],
        },
      },
    },
    batchUpdateShortcuts: {
      name: "BatchUpdateShortcuts",
      requestType: BatchUpdateShortcutsRequest,
      requestStream: false,
      responseType: BatchUpdateShortcutsResponse,
      responseStream: false,
      options: {},
    },
    /** UpdateShortcut updates a shortcut. */
    updateShortcut: {
      name: "UpdateShortcut",
      requestType: UpdateShortcutRequest,
      requestStream: false,
      responseType: UpdateShortcutResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [
            new Uint8Array([
              20,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              44,
              117,
              112,
              100,
              97,
              116,
              101,
              95,
              109,
              97,
              115,
              107,
            ]),
          ],
          578365826: [
            new Uint8Array([
              43,
              58,
              8,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              26,
              31,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
              47,
              123,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              46,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
    updateShortcuts: {
      name: "UpdateShortcuts",
      requestType: UpdateShortcutsRequest,
      requestStream: false,
      responseType: UpdateShortcutsResponse,
      responseStream: false,
      options: {},
    },
    /** DeleteShortcut deletes a shortcut by name. */
    deleteShortcut: {
      name: "DeleteShortcut",
      requestType: DeleteShortcutRequest,
      requestStream: false,
      responseType: DeleteShortcutResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([2, 105, 100])],
          578365826: [
            new Uint8Array([
              24,
              42,
              22,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
              47,
              123,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
    batchDeleteShortcuts: {
      name: "BatchDeleteShortcuts",
      requestType: BatchDeleteShortcutsRequest,
      requestStream: false,
      responseType: BatchDeleteShortcutsResponse,
      responseStream: false,
      options: {},
    },
    /** GetShortcutAnalytics returns the analytics for a shortcut. */
    getShortcutAnalytics: {
      name: "GetShortcutAnalytics",
      requestType: GetShortcutAnalyticsRequest,
      requestStream: false,
      responseType: GetShortcutAnalyticsResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([2, 105, 100])],
          578365826: [
            new Uint8Array([
              34,
              18,
              32,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              115,
              104,
              111,
              114,
              116,
              99,
              117,
              116,
              115,
              47,
              123,
              105,
              100,
              125,
              47,
              97,
              110,
              97,
              108,
              121,
              116,
              105,
              99,
              115,
            ]),
          ],
        },
      },
    },
  },
} as const;

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function toTimestamp(date: Date): Timestamp {
  const seconds = date.getTime() / 1_000;
  const nanos = (date.getTime() % 1_000) * 1_000_000;
  return { seconds, nanos };
}

function fromTimestamp(t: Timestamp): Date {
  let millis = (t.seconds || 0) * 1_000;
  millis += (t.nanos || 0) / 1_000_000;
  return new Date(millis);
}
